package com.ait.commonutils;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;


/*
 * 
 *通用的返回的类 
 * 
 * */


@Data
public class Msg {
	private Boolean success;
	//状态码 200-成功 201-失败
	private int code;
	//提示 状态
	private String message;
	//数据
	private Map<String, Object> data = new HashMap<>();

	private Msg(){};

	public static Msg success(){
		Msg result = new Msg();
		result.setSuccess(true);
		result.setCode(200);
		result.setMessage("处理成功");
		return result;
	}
	public static Msg fail(){
		Msg result = new Msg();
		result.setSuccess(false);
		result.setCode(201);
		result.setMessage("处理失败");
		return result;
	}


	public Msg code(Integer code){
		this.setCode(code);
		return this;
	}
	public Msg success(Boolean success){
		this.setSuccess(success);
		return this;
	}


	public Msg message(String message){
		this.setMessage(message);
		return this;
	}


	public Msg data(String str,Object obj){
		this.data.put(str,obj);
		return this;
	}

	public Msg data(Map<String,Object> map){
		this.setData(map);
		return this;
	}



	
	
}
